<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$title}</title>
    <meta name="keywords" content="{$title}">
    <meta name="description" content="{$title}">
    <link href="__ADMINCSS__/bootstrap.min14ed.css" rel="stylesheet">
    <link href="__ADMINCSS__/style.min.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加商品分类</h5>
                    <div class="ibox-tools">
                    </div>
                </div>
                <div class="ibox-content">
                    <form method="post" id="form1" name="form1" class="form-horizontal" action="{:U()}">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">所属父级商品分类：</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="pid" id="pid">
                                    <option value="0">————顶级商品分类————</option>
                                    <volist name="classification_info" id="v">
                                        <option value="{$v.id}">
                                            <?php
                                                if($v['level']==1){
                                                    echo $v['classification'];
                                                }else{
                                                    echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                                                    for($i = 1; $i < $v['level']; $i++){
                                                        echo '-----';
                                                    }
                                                    echo $v['classification'];
                                                }
                                            ?>
                                        </option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品分类名：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="classification_name" name="classification_name">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">添 加</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__ADMINJS__/jquery.min.js"></script>
<script src="__ADMINJS__/jquery.form.js"></script>
<script src="__ADMINJS__/plugins/layer/layer.min.js"></script>
<script src="__ADMINJS__/common.js"></script>
<script>
    $(function(){
        $('#form1').ajaxForm({
            beforeSubmit: checkFun,
            success: complete,
            dataType: 'json'
        });
        function checkFun(){
            if($('#pid').val() == undefined){
                sxshop.error('不要让你的商品分类没有父亲！');
                return false;
            }
            if($('#classification_name').val() == ''){
                sxshop.error('商品分类名不能为空！');
                return false;
            }
        }
        function complete(data){
            if(data.state > 0){
                sxshop.error(data.msg);
                return false;
            }else{
                sxshop.success(data.msg,'{:U("index")}')
            }
        }
    })
</script>
</body>
</html>
